package org.pz.entity;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 统一返回结果
 * */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@NoArgsConstructor
@AllArgsConstructor
public class MallResult implements Serializable {
    private Integer code;
    private String msg;
    private Object data;

    public static MallResult success(Object data) {
        return new MallResult(200, "success", data);
    }

    public static MallResult success() {
        return new MallResult(200, "success", null);
    }

    public static MallResult error(String msg) {
        return new MallResult(500, msg, null);
    }

    public static MallResult notFound(){
        return new MallResult(404, "not found", null);
    }

    public static MallResult accessDenied(){
        return new MallResult(403, "access denied", null);
    }

    public static MallResult forbidden(){
        return new MallResult(401, "forbidden", null);
    }
}
